import store from '../store';
import { setDebounce } from "@/hooks/DebounceHandle";
function handleResize(){
    const isMobile = getIsMobile();
    const { state } = store;
    if(state.isMobile === isMobile) return;
    store.commit('setIsMobile', isMobile);

    if (isMobile) {
        // store.commit('setIsUnfold', false)
    }
}
function getIsMobile(){
    const { body } = document;
    const rect = body.getBoundingClientRect();
    console.log(rect.width);
    return rect.width < 768;
}
export function useOnResize () {
    handleResize();
    window.addEventListener('resize', setDebounce(handleResize, 300));
}
export function destroyOnResize () {
    window.removeEventListener('resize', setDebounce(handleResize, 300));
}